package com.hfxt.service;

import com.hfxt.entity.Bill;
import com.hfxt.mapper.BillMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author WangXiaoTian
 * @version 1.0.0
 * @ClassName BillServiceImpl.java
 * @Description TODO
 * @createTime 2021年 03月 22日 04:52:00
 */
@Service("billService")
public class BillServiceImpl implements BillService {
    @Resource
    private BillMapper billMapper;

    //根据供应商id查询是否有未付款的订单
    @Override
    public List<Bill> queryBillsByProviderId(Long id) {
        return billMapper.queryBillsByProviderId(id);
    }

    //根据供应商id删除该供应商的所有已付款订单
    @Override
    public int deleteBillsByProviderId(Long id) {
        return billMapper.deleteBillsByProviderId(id);
    }

    //条件分页
    @Override
    public List<Bill> queryAllBillsByCondition(String productName, Integer providerId, Integer isPayment, Integer pageIndex, Integer pageSize) {
        return billMapper.queryAllBillsByCondition(productName, providerId, isPayment, (pageIndex - 1) * pageSize, pageSize);
    }

    //条件分页 获取记录数
    @Override
    public int queryCountByCondition(String productName, Integer providerId, Integer isPayment) {
        return billMapper.queryCountByCondition(productName, providerId, isPayment);
    }

    //根据id获得订单详情
    @Override
    public Bill queryBillById(Long id) {
        return billMapper.queryBillById(id);
    }

    //删除订单
    @Override
    public int deleteBillById(Long id) {
        return billMapper.deleteBillById(id);
    }

    //修改订单
    @Override
    public int updateBill(Bill bill) {
        return billMapper.updateBill(bill);
    }

    //新增订单
    @Override
    public int addBill(Bill bill) {
        return billMapper.addBill(bill);
    }

    @Override
    public Bill queryBillByProCode(String billCode) {
        return billMapper.queryBillByProCode(billCode);
    }

    @Override
    public List<Bill> queryAllBills() {
        return billMapper.queryAllBills();
    }
}
